/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Utilities;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author BarcelonaFC
 */
public class DBConnection {
     public static Connection GetConnection()
    {
          try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection cnn = DriverManager.getConnection("jdbc:odbc:ShopQuanAo_J2EE");
              return cnn;
          }catch(Exception e)
          {
              System.out.print(e);
              return null;
          }
    }
    public static int executeQueryString(String qry)
    {
        try{
            Statement st = GetConnection().createStatement();
            return st.executeUpdate(qry);

        }catch(Exception e)
        {
             System.out.print(e);
             return -1;
        }
    }
    public static ResultSet getResultSet(String qry)
    {
        try{
            Statement st = GetConnection().createStatement();
            ResultSet rs = st.executeQuery(qry);
            return rs;
        }
        catch(Exception e)
        {

            System.out.print(e);
            return null;

        }
    }
}
